package com.itya.weatherback.utils;

import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;
import com.alibaba.fastjson.JSON;
import java.lang.reflect.Type;
import java.util.Map;

public class LifeIndexDetailToStringDeserializer implements ObjectDeserializer {
    @Override
    public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
        // 读取原始 JSON 对象
        Object obj = parser.parse();
        if (obj instanceof Map) {
            Map<String, Object> map = (Map<String, Object>) obj;
            // 提取 state 字段
            return (T) map.get("state");
        }
        return null;
    }

    @Override
    public int getFastMatchToken() {
        return 0;
    }
}
